package com.why.jvm.hotspot.src.share.vm.oops;

import lombok.Data;

import java.util.*;

/**
 * @author xiaoTian
 * @date 2022/7/16
 * @Description:
 */
@Data
public class ConstantPool {

    public static final int CONSTANT_Utf8 = 1;

    public static final int CONSTANT_Integer = 3;

    public static final int CONSTANT_Float = 4;

    public static final int CONSTANT_Long = 5;

    public static final int CONSTANT_Double = 6;

    public static final int CONSTANT_Class = 7;

    public static final int CONSTANT_String = 8;

    public static final int CONSTANT_Fieldref = 9;

    public static final int CONSTANT_Methodref = 10;

    public static final int CONSTANT_InterfaceMethodref = 11;

    public static final int CONSTANT_NameAndType = 12;

    public static final int CONSTANT_MethodHandle = 15;

    public static final int CONSTANT_MethodType = 16;

    public static final int CONSTANT_InvokeDynamic = 18;

    private int count;

    private int[] tag;

    private Map<Integer,Object> constantPoolMap;

    public void initConstantPool(){
        tag = new int[count];
        constantPoolMap = new HashMap<>(count);
    }

    @Override
    public String toString() {
        return "ConstantPool{" +
                "count=" + count + '\n'+
                ", constantPoolMap=" + constantPoolMap +'\n'+
                '}';
    }
}
